import com.by.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;
import com.by.entity.tb;
import org.junit.Test;
import com.by.dao.tbDao;
import java.util.*;

public class MyTest2 {
    SqlSession session = SqlSessionFactoryUtil.getSqlSession();
    tbDao tbDao = session.getMapper(tbDao.class);
    @Test
    public void testSelectOne(){
        SqlSession session = SqlSessionFactoryUtil.getSqlSession();
        /*tb tb = session.selectOne("selecttb",10);
        System.out.println(tb.getUser_name());*/

        List<tb> list = session.selectList("getAlltbs");
        for (tb e:list) {
            System.out.println(e.getUser_name());
        }
    }

    /*
    *set迭代（迭代器）
    */
    public void testSetIter(){
        Set<tb> tbSet = new HashSet<tb>();
        Iterator<tb> tbIts = tbSet.iterator();

        while(tbIts.hasNext()){
            System.out.println(tbIts.next().getUser_name());
        }
    }

    @Test
    public void testtbPage(){
        List<tb> list = querytbByPage(2,5);
        for (tb e:list) {
            System.out.println(e.getId()+","+e.getUser_name());
        }
    }

    public List querytbByPage(int pageNum,int pageSize){
        Map<String,Object> params = new HashMap<String,Object>();
        params.put("pageNum",pageSize * (pageNum - 1));
        params.put("pageSize",pageSize);

        List<tb> list = tbDao.gettbsByPage(params);
        return list;
    }
@Test
    public void testtbCount(){
        System.out.println(tbDao.gettbCount());
    }

}
